package cn.trs.common.exception;

import cn.trs.common.enums.ErrorCodeEnum;

/**
 * @version 1.0
 * @author:王元晨
 * @create:2023/11/3 13:52
 * @description:系统异常类
 * @ClassName: SystemException
 * @company TRS
 */
public class SystemException extends RuntimeException {
    private String code;
    private String message;
    private String method;
    private boolean success = false;

    public SystemException(String code) {
        this.code = code;
        this.message = ErrorCodeEnum.getCodeMessage(code);
    }

    public SystemException(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public SystemException(String code, String message, String method) {
        this.code = code;
        this.message = message;
        this.method = method;
    }

    public SystemException(String code, String message, String method, Throwable cause)  {
        super(cause);
        this.code = code;
        this.message = message;
        this.method = method;
    }

    public SystemException(String code, String message, Throwable cause) {
        super(cause);
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }
}

